package threadpool;

import sun.applet.Main;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * ClassName: ScheduleThreadPoolTest
 * Package: threadpool
 *
 * @Author 马学兴
 * @Create 2024/3/14 14:12
 * @Version 1.0
 * Description:
 */
public class ScheduleThreadPoolTest {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
        for (int i = 0; i <10; i++) {
            //  scheduledExecutorService.schedule(new Task(),5, TimeUnit.SECONDS);
            scheduledExecutorService.scheduleAtFixedRate(new Task(),1,3,TimeUnit.SECONDS);
        }

    }
    static class Task implements Runnable{

        @Override
        public void run() {

            System.out.println(Thread.currentThread().getName());
        }
    }
}
